package com.liuceng.zen.service;

import com.liuceng.zen.mapper.LandingPageFormMapper;
import com.liuceng.zen.mapper.LandingPageMapper;
import com.liuceng.zen.pojo.domain.LandingPageForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by yanwen on 16-11-2.
 * LandingPageFormService :
 */
@Service
public class LandingPageFormService extends BaseService<LandingPageForm>{
    @Autowired
    private LandingPageFormMapper landingPageFormMapper;

    //通过formId 查找已经被落地页引用的表单
    public int getNumber(Integer formId){
        Map<String,Object> map=new HashMap<>();
        map.put("formId",formId);
        List<LandingPageForm> landingPageForms=landingPageFormMapper.findByParams(map);
        return landingPageForms==null?0:landingPageForms.size();
    }
    //通过landingPageId删除中间关联表记录
    public int deleteByLandingPage(Integer landingPageId){
        Map<String,Object> map=new HashMap<>();
        map.put("landingPageId",landingPageId);
        landingPageFormMapper.delete(map);
        return landingPageId;
    }
}
